package com.dragon.modules.yuegou.service.impl.member;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dragon.modules.yuegou.entity.member.ProDiscountEntity;
import com.dragon.modules.yuegou.mapper.member.ProDiscountMapper;
import com.dragon.modules.yuegou.model.member.ProDiscount;
import com.dragon.modules.yuegou.service.member.ProDiscountService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;

/**
 * 商品折扣表 服务实现
 *
 * @author pbuilder generated
 * @date 2021-12-15 09:38:01
 * @version 2.0
 */
@Service("memProDiscountService")
public class ProDiscountServiceImpl
		extends ServiceImpl<ProDiscountMapper, ProDiscountEntity>
		implements ProDiscountService {


	@Override
	public void saveProDiscount(ProDiscount proDiscount) {
		if(StringUtils.isNoneEmpty(proDiscount.getId())){
			proDiscount.setModifiedTime(LocalDateTime.now());
			baseMapper.updateById(proDiscount);
		}else{
			proDiscount.setCreatedTime(LocalDateTime.now());
			save(proDiscount);
		}
	}

	@Override
	public void copyProDiscount(String id) {
		ProDiscountEntity proDiscount = getById(id);
		proDiscount.setId(null);
		save(proDiscount);
	}

	@Override
	public void updateStatus(ProDiscount proDiscount) {
		ProDiscountEntity discount = getById(proDiscount.getId());
		discount.setEnableStatus(proDiscount.getEnableStatus());
		baseMapper.updateById(discount);
	}

}